<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
<!-- 导出  -->
<script type="text/javascript"
	src="${path }/resource/plugin/ajaxfileupload.js"></script>
<style>
.ibox-content {
	position: relative
}

.money {
	position: absolute;
	bottom: -12px;
	right: 110px;
	font-size: 20px;
	color: #3983de;
}
</style>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>统计管理<span>&gt;</span>班级收入成本表
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
		<!-- 搜索框部分start -->
		<p:btn value="serch">
			<form class="form-inline" id="serchform">

				<div class="form-group mr-20 ">
					<label for="exampleInputName2">学生学号</label> <input
						class="form-control" name="stuNo" id="stuNo" type="text">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">学生姓名</label> <input
						class="form-control" name="stuName" id="stuName" type="text">
				</div>

				<label for="exampleInputName2">班级</label>
				<div class="form-group mr-20">
					<div style="width: 160px;">
						<select name="claName" id="claName"
							class="form-control autoFull select2"
							data-url="${path}/admin/tabClass/showAllClass"
							data-filed="claName" data-value="claName">
							<option value="">--请选择所在班级--</option>
						</select>
					</div>
				</div>

				<br />
				<br /> <label for="exampleInputName2">院校</label>
				<div class="form-group mr-20">
					<div style="width: 160px;">
						<select name="stuSchool" id="stuSchool"
							class="form-control autoFull select2"
							data-url="${path}/admin/studentinfo/showAllSchool"
							data-def="${obj.stuSchool }" data-filed="name" data-value="name"
							datatype="*" nullmsg="院校不能为空">
							<option value="">--请选择所在学校--</option>
						</select>
					</div>
				</div>

				<label for="exampleInputName2">状态</label>
				<div class="form-group mr-20">
					<div style="width: 160px;">
						<select name="stuStatus" id="stuStatus"
							class="form-control autoFull select2"
							data-url="${path}/admin/studentinfo/showStuStatus"
							data-def="${obj.stuStatus }" data-filed="name" data-value="name">
							<option value="">--请选择状态--</option>
						</select>
					</div>
				</div>

				<button onclick="myGrid.serchData()" type="button"
					class="btn btn-info btn-sm">
					<i class="fa fa-search "></i> 搜索
				</button>
				<button type="button" onclick="MForm.reset('#serchform')"
					class="btn btn-info btn-sm">
					<i class="fa fa-refresh "></i> 重置
				</button>

			</form>
		</p:btn>
		<!-- 搜索框部分en -->
		<div class="option-bar">
			<p:btn value="dels">
				<button onclick="myGrid.delItems('sId')" type="button"
					class="btn btn-danger btn-sm">
					<i class="fa fa-trash"></i>批量删除
				</button>
			</p:btn>
			<p:btn value="add">
				<button onclick="openAdd()" type="button"
					class="btn btn-success btn-sm">
					<i class="fa fa-plus"></i> 新增
				</button>
			</p:btn>
			<p:btn value="import">
				<button onclick="openImport()" type="button"
					class="btn btn-warning btn-sm">
					<i class="fa fa-cloud-upload"></i> 导入
				</button>
			</p:btn>
			<p:btn value="export">
				<button onclick="exportExcel()" type="button"
					class="btn btn-info btn-sm">
					<i class="fa fa-cloud-download"></i> 导出
				</button>
			</p:btn>
		</div>
		<table id="mgrid">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-formatter="MGrid.indexfn" data-align="center"
						data-width="50px">序号</th>
					<th data-field="stuNo">学号</th>
					<th data-field="stuName">学生姓名</th>
					<th data-field="stuSchool">毕业院校</th>
					<th data-field="stuIfschool">是否院校毕业</th>
					<th data-field="claName">班级</th>
					<th data-field="stuStatus">状态</th>
					<th data-field="payable">应交学费</th>
					<th data-field="tInTuition">已交学费</th>
					<th data-field="tUnTuition">未交学费</th>
					<th data-field="biMoney">已领奖金金额</th>
					<th data-field="maMoney">管理费金额</th>
					<th data-field="tuiMoney">退费金额</th>
					<th data-field="pLoss">盈亏金额</th>
					<th data-field="stuRemark">备注</th>
				</tr>
			</thead>
		</table>
		<div class="money">
			<font>总应交学费：<span id="payables"></span></font> ,
			<font>总已交学费：<span id="tInTuitions"></span></font> ,
			<font>总未交学费：<span id="tUnTuitions"></span></font> ,
			<br/>
			<font>总已领奖金：<span id="biMoneys"></span></font> ,&nbsp; <font>总已领管理费：<span
				id="manageTotals"></span></font>,&nbsp; <font>总退费金额：<span
				id="tuiNummoneys"></span></font>,&nbsp; <font>总盈亏：<span id="pLosss"></span></font>
		</div>
	</div>

	<script type="text/javascript">
		var myGrid;
		$(function() {
			//带搜索的下拉框
			$(".select2").select2({
				'width' : '100%'
			});
			$(".select2").trigger("blur");
			//初始化下拉框
			MTools.autoFullSelect();
			//初始化日期控件
			MTools.ininDatetimepicker({
				listenBlur : true
			});

			//有删除权限
			var delUrl = "";
			<p:btn value="dels">
			delUrl = "${path}/admin/costCount/del";
			</p:btn>

			myGrid = MGrid.initGrid({
				url : "${path}/admin/classCost/inPage",
				delUrl : delUrl,
				onLoadSuccess : function(data) {
					$.AjaxProxy({
						p : {
							stuNo : $("#stuNo").val(),
							stuName : $("#stuName").val(),
							claName : $("#claName").val(),
							stuSchool : $("#stuSchool").val(),
							stuStatus : $("#stuStatus").val(),
						}
					}).invoke(
							"${path}/admin/classCost/model",
							function(loj) {
								var payables = 0; // 总应交学费
								var tInTuitions = 0; //总已交学费
								var tUnTuitions = 0; //总未交学费
								var biMoneys = 0; //总奖金
								var manageTotals = 0; //总管理费
								var tuiNummoneys = 0; //总退费金额
								var pLosss = 0; //盈亏金额
								for (var i = 0; i < loj.getRowCount(); i++) {
									payables += new Number(loj.getString(i,
											"payable"));
									tInTuitions += new Number(loj.getString(i,
											"tInTuition"));
									tUnTuitions += new Number(loj.getString(i,
											"tUnTuition"));
									biMoneys += new Number(loj.getString(i,
											"biMoney"));
									manageTotals += new Number(loj.getString(i,
											"maMoney"));
									tuiNummoneys += new Number(loj.getString(i,
											"tuiMoney"));
									pLosss += new Number(loj.getString(i,
											"pLoss"));
								}
								$("#payables").html(payables);
								$("#tInTuitions").html(tInTuitions);
								$("#tUnTuitions").html(tUnTuitions);
								$("#biMoneys").html(biMoneys);
								$("#manageTotals").html(manageTotals);
								$("#tuiNummoneys").html(tuiNummoneys);
								$("#pLosss").html(pLosss);
							});
				}
			});
		});
		function buidOperate(value, row, index) {
			var html = '';
			<p:btn value="edit">
			html += '<button class="btn btn-default btn-sm mr-5" onClick="openEdit('
					+ value
					+ ')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			</p:btn>
			<p:btn value="del">
			html += '<button class="btn btn-default btn-sm" onClick="myGrid.delItem('
					+ value
					+ ')" title="删除"><i class="fa fa-lg fa-trash-o"></i></buttoun>';
			</p:btn>
			html += ''
			return html;
		}
		//打开添加界面
		<p:btn value="add">
		function openAdd() {
			layer.open({
				type : 2,
				title : "添加学生",
				area : [ MUI.SIZE_L, '560px' ],
				maxmin : true,
				content : [ '${path}/admin/studentinfo/editForm' ]
			});
		}
		</p:btn>

		//打开编辑界面
		<p:btn value="edit">
		function openEdit(id) {
			layer.open({
				type : 2,
				title : "编辑学生",
				area : [ MUI.SIZE_L, '560px' ],
				maxmin : true,
				content : [ '${path}/admin/studentinfo/editForm?id=' + id ]
			});
		}
		</p:btn>

		<p:btn value="import">
		function openImport() {
			//弹出修改框
			layer.open({
				type : 2,
				title : "批量导入",
				area : [ MUI.SIZE_L, '480px' ],
				maxmin : true,
				content : [ '${path}/admin/redirect/studentImportDialog' ]
			});
		}
		</p:btn>

		<p:btn value="export">
		function exportExcel() {
			/* var sNo = $("#sNo").val();
			var sName = $("#sName").val();
			var tClass = $("#tClass").val();
			var tPaying = $("#tPaying").val();
			var beginTime = $("#beginTime").val();
			var endTime = $("#endTime").val(); */
			window.location.href = "${path}/admin/classCost/exportExcel";
		}
		</p:btn>

		function transform(value, row, index) {
			var x = row.tUnTuition;
			var isNot = "";
			if (x > 0) {
				isNot = "否";
			} else if (x == 0 || x < 0) {
				isNot = "是";
			}
			return isNot;
		}
	</script>
</body>
</html>
